package tutorial.java.swing;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class ConfirmDialogDemo extends JFrame{
	public ConfirmDialogDemo(){
		super("Confirm Dialog Demo");
		setSize(500,400);
		setVisible(true);
		setLocationRelativeTo(null);
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JLabel label = new JLabel("Hai Oanh");
		add(label);
		
		JButton button = new JButton("Click Here");
		add(button, "North", 1);
		
		button.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				int click = JOptionPane.showConfirmDialog(null, "Is Hai handsome ? ");
				if (click == JOptionPane.YES_OPTION) {
					JOptionPane.showMessageDialog(null, "Click Yes");
				}
				if (click == JOptionPane.NO_OPTION) {
					JOptionPane.showMessageDialog(null, "Click No");
				}
				if (click == JOptionPane.CANCEL_OPTION) {
					JOptionPane.showMessageDialog(null, "Click Cancel");
				}
			}
		});
		
	} 
	
	public static void main(String[] args){
		ConfirmDialogDemo cf = new ConfirmDialogDemo();
	}
}
